home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / web / spiderweb / tools / tie / error.web < prev    next >
Text File  |  1992-07-05  |  2KB  |  57 lines

  1. @* Reporting errors to the user.
  2.  
  3. \noindent There may be errors if a line in a given change
  4. file does not match a line in the master file or a
  5. replacement in a previous change file.    Such errors are
  6. reported to the user by saying
  7. $$
  8.    \hbox{|err_print('!  Error message')|.}
  9. $$
  10. Please note that no trailing point is supplied by the error
  11. message because it is appended by |err_print|.    Non
  12. recoverable errors are handled by calling |fatal_error| that
  13. outputs a message and then calls `|jump_out()|'.
  14.  
  15. \leavevmode |err_print| will print the error message
  16. followed by an indication of where the error was spotted in
  17. the source files.  |fatal_error| cannot state any files
  18. because the problem is usually to access these.
  19.  
  20. For |err_print| messages the following procedure is used to
  21. write the proper name of an input file.
  22.  
  23. @d fatal_error(X) = {print_nl(X); print_ln("."); history=fatal; jump_out();}
  24.  
  25. @<Error handling...@>=
  26.  print_name_of_file(cur_index)
  27.     file_index cur_index;
  28. {
  29.   fprintf(stderr,"%s",input_organization[cur_index].name_of_file);
  30. }
  31.  
  32.  
  33. @ The actual error indications are provided by a procedure
  34. called |err_loc|.
  35.  
  36. @<Error handling...@>=
  37.  err_loc(i) /* prints location of error */
  38. int i;
  39. {
  40.     fprintf(stderr,
  41.         " (file %s, l.%d).\n",input_organization[i].name_of_file,
  42.         input_organization[i].lineno);
  43. @^system dependencies@>
  44. }
  45.  
  46. @ If it is necessary to abort the job because of a fatal
  47. error, the program calls the `|jump_out()|' procedure, which
  48. does something system-dependent.
  49. @^system dependencies@>
  50. @ The |jump_out()| procedure just cuts across all active
  51. procedure levels and jumps out of the program.    
  52. It is implemented by a call to |exit()|.
  53. @^system dependencies@>
  54.  
  55. @<Error handling...@>=
  56.  jump_out() { exit(history==spotless ? 0 : 1);}
  57.